{% extends "base_project.html" %}
{% load humanize static hc_extras %}

{% block title %}Matrix Integration for {{ site_name }}{% endblock %}

{% block content %}
<div class="row">
<div class="col-sm-12">
    <h1>Matrix</h1>

    <p>
    If your team uses <a href="https://matrix.org/">Matrix</a>,
    you can set up {{ site_name }} to post notifications
    to an appropriate Matrix room.
    </p>

    <h2>Setup Guide</h2>
    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            <div>
                <p>
                Invite <strong>{{ matrix_user_id }}</strong>
                into your Matrix room.
                </p>
                <p>
                    <strong>Note:</strong> after joining the room,
                    {{ matrix_user_id }} will be
                    able to read its messages.
                    Do not invite to rooms with sensitive content.
                    Consider creating a dedicated room for notifications.
                </p>
            </div>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_1.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            <p>
                Navigate to the <strong>Room Settings › General</strong> screen
                and look up the room's <strong>Published Address</strong>.
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_2.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            <p>
                If the room does not have a Published Address,
                look up its <strong>Internal Room ID</strong>
                from the <strong>Room Settings › Advanced</strong> screen instead.
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_3.png' %}">
        </div>
    </div>

    <div class="row ai-step">
        <div class="col-sm-6">
            <span class="step-no"></span>
            <p>
                Enter the Published Address or the Internal Room ID
                in the form below and save the integration.
            </p>
            <p>
                {{ matrix_user_id }} will shortly join your room. After that,
                you are all set! From now on {{ site_name }} will post notifications
                to your room when checks go down or up.
            </p>
        </div>
        <div class="col-sm-6">
            <img
                class="ai-guide-screenshot"
                alt="Screenshot"
                src="{% static 'img/integrations/setup_matrix_4.png' %}">
        </div>
    </div>

    <h2>Integration Settings</h2>

    <form method="post" class="form-horizontal">
        {% csrf_token %}

        <div class="form-group {{ form.alias.css_classes }}">
            <label for="alias" class="col-sm-2 control-label">Address or Internal ID</label>
            <div class="col-sm-6">
                <input
                    id="alias"
                    type="text"
                    class="form-control"
                    name="alias"
                    placeholder="#alias:matrix.org"
                    value="{{ form.alias.value|default:"" }}">

                {% if form.alias.errors %}
                <div class="help-block">
                    {{ form.alias.errors|join:"" }}
                </div>
                {% endif %}
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">Save Integration</button>
            </div>
        </div>
    </form>
</div>
</div>
{% endblock %}
